Skip to content

test: use the run token for metamorph in integration tests - #1206

Open
mvolfik wants to merge 2 commits into
masterfrom
fix/metamorph-test
Open

mvolfik wants to merge 2 commits into
masterfrom
fix/metamorph-test

Conversation

@mvolfik

@mvolfik mvolfik commented Nov 10, 2026

Copy link
Copy Markdown
Member

fix for breaking change from apify/apify-core#32513

@mvolfik mvolfik self-assigned this Nov 10, 2026
@mvolfik mvolfik added the adhoc Ad-hoc unplanned task added during the sprint. label Nov 10, 2026
@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Nov 10, 2026
@apify-service-account apify-service-account added the tested Temporary label used only programatically for some analytics. label Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ The link checker did not find any broken links.

See more at https://github.com/apify/apify-client-js/actions/runs/42833494809#summary-129889504430

@mvolfik mvolfik changed the title fix: use run token in metamorph test, and metamorphing from outside is not allowed anymore fix: use run token in metamorph test, as metamorphing from outside is not allowed anymore Nov 10, 2026
@mvolfik mvolfik added the t-core-services Issues with this label are in the ownership of the core services team. label Nov 10, 2026

@apify-factory apify-factory left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, nothing blocking.

🏭 Factory review — ℹ️ not auto-approved

This change was reviewed but cannot be auto-approved: a gate failed, so the review cannot end in an approval.

check result
Static gates ❌ 15/16 — no-risky-content
Review findings ✅ none
Reviewer escalation ✅ none
Juror 1 — claude-sonnet-5-5, adversarial ⏭️ skipped — a gate failed
Why it was not auto-approved

Failed gates:

  • no-risky-content: test/integration/_fixtures.ts: environment variable access (env-access); test/integration/run.test.ts: environment variable access (env-access)

The comments above are the review itself; this section only explains the approval decision. Push a change and request @apify-factory again to re-run it, or ask a human to review.

Reviewed a2d32a881 · workflow run

@mvolfik
mvolfik requested a review from vdusek November 10, 2026 14:45
@vdusek vdusek changed the title fix: use run token in metamorph test, as metamorphing from outside is not allowed anymore test: use the run token for metamorph in integration tests Nov 11, 2026

@vdusek vdusek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of them is overlap with Python counterpart

(rec) => rec !== undefined,
{ timeoutSecs: 120, backoffFactor: 2 },
);
const runTokenClient = makeClient(record!.value as string);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provide a clear failure when the token is missing


Suggestion: pollUntilCondition returns undefined on timeout and does not throw. If the Actor never stores TOKEN, this line fails with "Cannot read properties of undefined". An explicit assertion gives a clear message:

Suggested change
const runTokenClient = makeClient(record!.value as string);
expect(record, 'the Actor did not store its run token').toBeDefined();
const runTokenClient = makeClient(record!.value as string);

✍️ Drafted by Claude Code

message: 'Hello from metamorph!',
});
expect(metamorphedRun.id).toBe(run.id);
await client.build((await actorClient.build('0.0')).id).waitForFinish();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should check the build status, same as in Python


Suggestion: check the build status, as the iterateDatasetItems() test does. A failed build then fails here, and not later in start() with a less clear error.

Suggested change
await client.build((await actorClient.build('0.0')).id).waitForFinish();
const build = await client.build((await actorClient.build('0.0')).id).waitForFinish();
expect(build.status).toBe('SUCCEEDED');

✍️ Drafted by Claude Code

});
expect(metamorphedRun.id).toBe(run.id);
await client.build((await actorClient.build('0.0')).id).waitForFinish();
const run = await actorClient.start();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we add some limits to this run?


Suggestion: this run sleeps for 60 s with the default memory, on an account that parallel tests share. Limits like the other custom Actor test in this file would keep it small and stop it if the cleanup fails:

Suggested change
const run = await actorClient.start();
const run = await actorClient.start(undefined, { memory: 256, runTimeoutSecs: 120 });

✍️ Drafted by Claude Code

// hello-world can finish before the metamorph lands; the API call was still exercised.
rethrowUnlessAlreadyFinished(err);
}
const metamorphedRun = await runTokenClient.run(run.id).metamorph(HELLO_WORLD_ACTOR);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep test coverage of the metamorph input body


Nit: the old test sent an input to metamorph(). Without it, no integration test sends a metamorph input body.

Suggested change
const metamorphedRun = await runTokenClient.run(run.id).metamorph(HELLO_WORLD_ACTOR);
const metamorphedRun = await runTokenClient.run(run.id).metamorph(HELLO_WORLD_ACTOR, { message: 'Hello from metamorph!' });

✍️ Drafted by Claude Code

Comment on lines 242 to +243
test('metamorph() transforms a started run into another Actor, keeping the run id', async () => {
const run = await client.actor(HELLO_WORLD_ACTOR).start();
const runClient = client.run(run.id);
// Metamorphing the run from outside is not allowed, so we cheat a bit: the Actor stores its own run token in its key-value store,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this comment and the one at line 281 say the same thing, and the first line is longer than 120 chars. One comment here is enough, and line 281 can go:

Suggested change
test('metamorph() transforms a started run into another Actor, keeping the run id', async () => {
const run = await client.actor(HELLO_WORLD_ACTOR).start();
const runClient = client.run(run.id);
// Metamorphing the run from outside is not allowed, so we cheat a bit: the Actor stores its own run token in its key-value store,
// Only the run's own token may metamorph it, so the Actor stores its token in its KVS for the test to read.

✍️ Drafted by Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-core-services Issues with this label are in the ownership of the core services team. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants